<?php
declare(strict_types=1);

namespace App\AdminApi\Modular\User\Validate;

use App\Common\Enums\StatusEnums;
use Core\Constants\Database;
use Zms\Validate\Type;
use Zms\Validate\ValidateAbstract;

class UserLevelValidate extends ValidateAbstract
{
    public function rules(): array
    {
        return [
            ['id', Type::REQUIRED, 'error' => '缺少必要参数', 'on' => ['updated']],

            ['name', Type::REQUIRED, 'on' => ['created', 'updated']],
            ['name', Type::STRING, 'max' => 20, 'on' => ['created', 'updated']],

            ['desc', Type::STRING, 'max' => 50, 'on' => ['created', 'updated']],

            ['sort', 'number', 'min' => Database::INT_MIN, 'max' => Database::INT_MAX, 'precision' => 0, 'on' => ['created', 'updated']],

            ['status', 'in', 'enums' => StatusEnums::Values(), 'on' => ['created', 'updated']]
        ];
    }


    public function labels(): array
    {
        return [
            'name' => '等级名称',
            'desc' => '等级备注',
            'sort' => '排序',
            'status' => '启用状态',
        ];
    }
}